home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 26 (Anniversary Edition)
/
Volume 26 [Anniversary Edition] - JOGO DISK .iso
/
DEPOSITO
/
REmovido
/
Puzzle
/
yeti.swf
/
scripts
/
__Packages
/
CMoveBall.as
< prev
next >
Wrap
Text File
|
2006-06-07
|
2KB
|
72 lines
class CMoveBall extends CBall
{
function CMoveBall()
{
super();
this.hide();
}
function startMove(x, y, vx_, vy_)
{
var _loc1_ = this;
_loc1_._x = _loc1_.sX = x;
_loc1_._y = _loc1_.sY = y;
_loc1_.vx = vx_;
_loc1_.vy = vy_;
_loc1_.curR = 0;
_loc1_.calcEndPoint();
_loc1_.show();
}
function doStep(step)
{
var _loc1_ = this;
_loc1_.curR += step;
if(_loc1_.curR >= _loc1_.commonR)
{
_loc1_.sX = _loc1_.eX;
_loc1_.sY = _loc1_.eY;
_loc1_.curR = 0;
_loc1_.vx = - _loc1_.vx;
_loc1_.calcEndPoint();
}
_loc1_._x = _loc1_.sX + _loc1_.curR * _loc1_.vx;
_loc1_._y = _loc1_.sY + _loc1_.curR * _loc1_.vy;
}
function calcEndPoint()
{
var _loc1_ = this;
var _loc3_ = undefined;
var _loc2_ = undefined;
var C;
var d;
_loc1_.sX -= _loc1_.mc_grid._x;
_loc1_.sY -= _loc1_.mc_grid._y;
_loc1_.eX = _loc1_.sX + 1000 * _loc1_.vx;
_loc1_.eY = _loc1_.sY + 1000 * _loc1_.vy;
_loc3_ = _loc1_.sY - _loc1_.eY;
_loc2_ = _loc1_.eX - _loc1_.sX;
C = _loc1_.sX * (_loc1_.eY - _loc1_.sY) - _loc1_.sY * (_loc1_.eX - _loc1_.sX);
d = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
_loc3_ /= d;
_loc2_ /= d;
C /= d;
var p = _loc1_.mc_grid.getBoundsIntersection(_loc1_.vx,_loc1_.vy,_loc3_,_loc2_,C);
_loc1_.eX = p.x;
_loc1_.eY = p.y;
_loc1_.commonR = Math.sqrt((_loc1_.eX - _loc1_.sX) * (_loc1_.eX - _loc1_.sX) + (_loc1_.eY - _loc1_.sY) * (_loc1_.eY - _loc1_.sY));
_loc1_.sX += _loc1_.mc_grid._x;
_loc1_.sY += _loc1_.mc_grid._y;
_loc1_.eX += _loc1_.mc_grid._x;
_loc1_.eY += _loc1_.mc_grid._y;
}
function show()
{
this._visible = true;
this.state = 1;
}
function hide()
{
this._visible = false;
this.state = 0;
}
}